const http = require('http')
const fs = require('fs')
const zlib = require('zlib')
http
  .createServer(function(request, response) {
    if (request.url === '/') {
      // console.log(Object.keys(request))
      // console.log(Object.keys(request.client))
      const body = fs.readFileSync('./index.html')
      response.writeHead(200, {
        'Content-Type': 'text/html',
        'Content-Encoding': 'gzip'
      })
      request.setEncoding('utf-8')
      request.on('data', function(res) {
        console.log(res)
      })
      response.end(zlib.gzipSync(body))
    }
  })
  .listen(8888)

console.log('server at 8888')
